<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>巡查台账</title>
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no" />
    <meta name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/globle.css" />
    <link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css" />
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <style>
        span {
            margin: 10px;
        }

        .Tabl {
            height: 50px;
            width: 88%;
            font-size: 14px;
            font-weight: bold;
            text-align: left;
            margin-left: 6%;
        }

        .Td1 {
            color: #b8b8b8;
            width: 110px;
        }

        .Td2 {
            color: #000000;
            text-align: left;
        }

        .Hr {
            height: 1px;
            width: 96%;
            background-color: #faf7f7;
            margin-left: 2%;
        }

        .Butt {
            border: 1px solid #b8b8b8;
            border-radius: 20px;
            color: #ffffff;
            height: 17px;
            width: 17px;
            outline: none;
        }

        .TabImg {
            height: 150px;
            width: 96%;
            margin-left: 2%;
            border: 10px solid #d8d8d8;
        }

        .TdImg1 {
            height: 110px;
            width: 90px;
        }

        .TdImg2 {
            height: 110px;
            width: 90px;
        }

        .ButAdd {
            height: 110px;
            width: 100px;
            font-size: 100px;
            color: #ffffff;
            background-color: #b8b8b8;
        }

        .TabL {
            height: 75px;
            width: 88%;
            font-size: 16px;
            font-weight: bold;
            text-align: left;
            margin-left: 6%;
        }

        .ButL {
            height: 40px;
            width: 100%;
            background-color: #d0d0d0;
            /* position: fixed; */
            bottom: 0;
        }

        .Td3 {
            background-color: #1abc9c;
            text-align: center;
            width: 50%;
        }

        select {
            appearance: none;
            -moz-appearance: none;
            -webkit-appearance: none;
            border: none;
            background: none;
        }
    </style>
</head>

<body>
    <button style="background-color: #F2F2F2;height: 40px;width: 100%;font-size: 18px;">发布维修区域</button>
    <input type="hidden" id="ids" />
    <input type="hidden" id="proId" />
    <table class="Tabl">
        <tr>
            <td class="Td1">发布人：</td>
            <td class="Td2">
                <input name="publishUser" id="publishUser" readonly placeholder="" />
            </td>
        </tr>
    </table>
    <hr class="Hr" />
    <table class="Tabl">
        <tr>
            <td class="Td1">预期时间：</td>
            <td class="Td2">
                <input type="date" id="completeTime" name="repairTime" />
            </td>
        </tr>
    </table>
    <hr class="Hr" />
    <table class="Tabl">
        <tr>
            <td class="Td1">维修内容：</td>
        </tr>
    </table>
    <table class="TabL">
        <tr>
            <td>
                <textarea rows="3" cols="35" id="repairContext" name="repairContext" placeholder=""></textarea>
            </td>
        </tr>
    </table>
    <hr class="Hr" />
    <table class="Tabl">
        <tr>
            <td class="Td1">标段名称：</td>
            <td class="Td2">
                <input value="" id="departProjectid" disabled="disabled" />
            </td>
        </tr>
    </table>
    <hr class="Hr" />
    <table class="Tabl">
        <tr>
            <td class="Td1">绿地名称：</td>
            <td class="Td2">
                <select id="urisId" name="urisId"> </select>
            </td>
        </tr>
    </table>
    <hr class="Hr" />
    <table class="Tabl">
        <tr>
            <td class="Td1">维修人员：</td>
            <td class="Td2">
                <select id="receiver" name="receiver"> </select>
            </td>
        </tr>
    </table>
    <hr class="Hr" />
    <table class="Tabl">
        <tr>
            <td class="Td1">发布时间：</td>
            <td class="Td2">
                <input type="date" disabled value="" id="createTime" />
            </td>
        </tr>
    </table>
    <hr class="Hr" />
    <div style="padding: 10px;">
        <ul class="upload-ul clearfix">
            <li class="upload-pick">
                <div class="webuploader-container clearfix" id="goodsUpload"></div>
            </li>
        </ul>
    </div>

    <hr class="Hr" />
    <table class="TabL">
        <tr>
            <td class="Td1">问题图片：</td>
        </tr>
    </table>
    <table class="TabL">
        <tr>
            <td>
                <div id="imgBox1"></div>
            </td>
        </tr>
    </table>

    <button style="background-color: #F2F2F2;height: 40px;width: 100%;font-size: 18px;">执行维修区域</button>
    <table class="ButL">
        <tr>
            <td class="Td3">
                <div style="color: #ffffff;" onclick="dlccte()">
                    删除
                </div>
            </td>
            <td class="Td3">
                <div style="color: #ffffff;" onclick="sublmt()">
                    完成
                </div>
            </td>
        </tr>
    </table>
    <div style="
        width: 80%;
        position: absolute;
        left: 10%;
        right: 10;
        top: 60%;
        z-index: 1000000;
        text-align: center;
      " id="bigImage">
        &nbsp;
    </div>
</body>
<script src="../../script/webuploader.js"></script>
<script src="../../script/jquery.js"></script>
<script src="../../script/diyUpload.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">
    //上传图片

    var $tgaUpload = $("#goodsUpload").diyUpload({
        url: BaseServiceUrl + "mobile/repairManage/uploadRepairImage.json",
        success: function (data) {
            //alert(JSON.stringify(data))
        },
        error: function (err) {
            alert(JSON.stringify(err));
        },
        buttonText: "",
        accept: {
            title: "Images",
            extensions: "gif,jpg,jpeg,bmp,png",
            mimeTypes: 'image/*'
        },
        thumb: {
            width: 600,
            height: 600,
            quality: 100,
            allowMagnify: false,
            crop: false,
            type: "image/jpeg",
        },
    });
    $tgaUpload.options.formData.dids = null;
    apiready = function () {
        var patrol = api.pageParam.patId;
        var sid = patrol;
        $.ajax({
            type: "post",
            async: false, //同步执行
            url: BaseServiceUrl + "mobile/repairManage/findRepairOne.json",
            data: {
                pid: Number(sid),
            },
            dataType: "json", //返回数据形式为json
            success: function (result) {
                var datas = result.obj;
                $("#source").val(datas.source);
                $("#situation").val(datas.situation);

                //给地赋值
                document.all.urisId;
                Option1 = document.createElement("Option");
                Option1.text = datas.greenName;
                Option1.value = datas.urisid;
                document.all.urisId.add(Option1);

                //给人赋值
                document.all.receiver;
                oOptiong = document.createElement("Option");
                oOptiong.text = datas.receiver;
                oOptiong.value = datas.receiverId;
                document.all.receiver.append(oOptiong);
                // document.all.greenBeltName.value = datas.id;
                $("#receiver").val(datas.receiver);
                $("#publishUser").val(datas.publishUser);
                $("#createTime").val(datas.createTime);
                $("#completeTime").val(datas.repairTime);
                $("#proId").val(datas.proId);
                $("#nuttertools").val(datas.areaId);
                $("#remark").val(datas.remark);
                $("#ids").val(datas.id);
                $("#repairContext").val(datas.repairContext)
            },
        });

        var ret = $api.getStorage("selectpor");
        if (ret != undefined) {
            $("#proId").val(ret.id);
            $("#departProjectid").val(ret.projectName);
            var sids = ret.id;

            $.ajax({
                type: "post",
                async: false, //同步执行
                url: BaseServiceUrl + "mobile/admin/list.json",
                data: {
                    areaid: sids.toString(),
                    proId: proId.toString(),
                },
                dataType: "json", //返回数据形式为json
                success: function (result) {
                    var v = result.obj;
                    var select = document.getElementById("urisId");
                    for (var i = 0; i < v.length; i++) {
                        var opt = document.createElement("option");
                        // 设置option元素的内容，内容为传入的数组内容
                        opt.innerText = v[i].greedLandAdministrator.name;
                        opt.value = v[i].id;
                        // 把option添加到select中
                        select.appendChild(opt);
                    }
                    $("#urisId").val(v.id);
                },
            });
        }
        var reg = $api.getStorage("userSession");
        //alert(JSON.stringify(reg))
        if (reg != undefined) {
            $("#nuttertools").val(reg.data.id);
            var sids = reg.data.enterprise.id;
            $("urisId").change(() => {
                $.ajax({
                    type: "post",
                    async: false, //同步执行
                    url: BaseServiceUrl + "mobile/admin/select.json",
                    data: {
                        sids: sids,
                    },
                    dataType: "json", //返回数据形式为json
                    success: function (result) {
                        var v = result.obj;
                        var select = document.getElementById("receiver");
                        $("#receiver").empty()
                        for (var i = 0; i < v.length; i++) {
                            var opt = document.createElement("option");
                            // 设置option元素的内容，内容为传入的数组内容
                            opt.innerText = v[i].name;
                            opt.value = v[i].id;
                            // 把option添加到select中
                            select.appendChild(opt);
                        }
                        $("#receiver").val(v.id);
                    },
                });
            });
        }
        var id = patrol;
        $.ajax({
            type: "post",
            //async : false, //同步执行
            url: BaseServiceUrl + "mobile/repairManage/viewAndImage.jhtml",
            data: {
                id: id,
            },
            dataType: "json", //返回数据形式为json
            success: function (result) {
                for (var i = 0; i < result.obj.length; i++) {
                    $("#imgBox1").append(
                        '<div style="margin-left:5px;float:left;margin-top:5px;"><img width="100" height="100"onclick=\'showBig(this)\'  src="' +
                        serverImage +
                        result.obj[i].image +
                        '"\/><\/div>'
                    );
                }
            },
        });
    };
    function outzhu(id) { }
    function showBig(t) {
        document.getElementById("bigImage").innerHTML =
            "<img src='" +
            t.src +
            "' onclick='closeBig(this)'  width='100%' style='border:3px solid #4f4f4f;'/>";
    }
    function closeBig(t) {
        document.getElementById("bigImage").innerHTML = "";
    }

    //删除巡查任务
    function dlccte() {
        var sid = $("#ids").val();
        $.ajax({
            url: BaseServiceUrl + "mobile/repairManage/deletePatrol.json",
            type: "POST",
            data: {
                sid: sid,
            },
            dataType: "json",
            async: false,
            success: function (ret) {
                alert("删除成功");
                api.closeWin();
            },
        });
    }
    //提交修改信息
    function sublmt() {
        var source = $("#repairContext").val();
        if (source == null || source == "") {
            alert("请输入维修内容");
            return false;
        }

        var completeTime = $("#completeTime").val();

        if (completeTime == null || completeTime == "") {
            alert("请输入要求完成时间");
            return false;
        }
        var proId = $("#proId").val();
        var remark = $("#remark").val();
        var id = $("#ids").val();
        //修改巡查信息
        $.ajax({
            url: BaseServiceUrl + "mobile/repairManage/updateByRepair.json",
            type: "POST",
            data: {
                remark: source,
                completeTime: completeTime,
                patrolId: id,
            },
            dataType: "json",
            async: false,
            success: function (result) {
                $tgaUpload.options.formData.dids = result.obj.id;
                $tgaUpload.upload();
                if (result.code == 0) {
                    api.showProgress({
                        //打开开关
                        title: "提交中...",
                        text: "",
                    });
                    setTimeout(function () {
                        api.closeWin();
                    }, 5000);
                }
            },
        });
    }
</script>

</html>